package org.chuan.hisports.controller;

import org.chuan.hisports.entity.Notice;
import org.chuan.hisports.service.NoticeService;
import org.chuan.hisports.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller("notice")
@RequestMapping("notice")
public class NoticeController {

    @Autowired
    NoticeService noticeService;

    @RequestMapping("selectAll")
    @ResponseBody
    public JSONResult selectAll(){
        List<Notice> list = noticeService.selectAll();
        return JSONResult.build(200,"success",list);
    }

    @RequestMapping("selectById")
    @ResponseBody
    public JSONResult selectById(@RequestParam("id") String id){
        Notice notice = noticeService.selectById(id);
        return JSONResult.build(200,"success",notice);
    }

    @RequestMapping("selectByType")
    @ResponseBody
    public JSONResult selectByType(@RequestParam("type") String type){
        List<Notice> list = noticeService.selectByType(type);
        return JSONResult.build(200,"success",list);
    }
}
